#include "espresso_based.h"
#include "ingredient.h"
#include <iterator>
#include <sstream>
#include <string>
#include <vector>

EspressoBased::EspressoBased() {}

EspressoBased::EspressoBased( const EspressoBased& cap )
: name(cap.name) , ingredients(cap.ingredients) {}

void EspressoBased::operator=(const EspressoBased& esp) {
    if( this != &esp ) {
        this->name        = esp.name;
        this->ingredients = esp.ingredients;
    }
    return;
}

void EspressoBased::brew() {
    std::vector<std::string> ig;
    for( const auto &i : ingredients ) {
        std::stringstream ss;
        ss << i->get_name() << " " << i->get_price_unit() << " " << i->get_units();
        ig.push_back(ss.str());
    }
    std::copy(ig.begin(),ig.end(),
        std::ostream_iterator<std::string>( std::cout , "\n" ));
    return;
}

std::vector<Ingredient*>& EspressoBased::get_ingredients() {
    return ingredients;
}